cmake_minimum_required(VERSION 3.10)
project(test_library LANGUAGES CXX)
add_library(add SHARED "source/add.cpp")
#CMAKE_CURRENT_SOURCE_DIR当前正在执行的CmakeLists.txt所在的目录
#CMAKE_BINARY_DIR整个项目"构建"根目录（build目录）
#有CURRENT就是当前正在执行的CMakeLists.txt，没有就是整个项目
#target_include_directories(add PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/source")
set_target_properties(add PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lib"
    INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/source"
    INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/source"
)
add_executable(main "${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp")
set_target_properties( main PROPERTIES
    #由于使用add目标，会自动将add目标的interface属性传递下来，也就是头文件路径被自动包含，不需要手动包含
    #INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/source"
    LINK_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/lib"
    LINK_LIBRARIES add
    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/output"
)